<?php

namespace app\index\controller;

use app\api\controller\mytool\SendMessage;
use app\common\model\Sync\SyncCenter;
use think\View;
use think\Controller;
use EasyWeChat\Factory;
use think\facade\Request;
use think\facade\Session;


class Index extends Controller
{
	public function index()
	{
		echo "1111";
		//$this->redirect(SUBSCRIPTIONUSERHOME);
	}

	public function cs(){//gl
		$key = 'e0f19c1b487e45f4aab7f84d452f20a1';
		$data = "{" .
            "\"entId\":\"2166171850491904\"," .
            "\"packageCode\":\"承德伟翔-20230408-0003\"".
            "}";

		$keyString =$key;
		$keyBytes = base64_decode($keyString);
		$key = substr($keyBytes, 0, 16);
		$iv = pack("C*", 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31);
		$result = openssl_encrypt($data, "sm4-cbc", $key, $options=0, $iv);
		echo($result);
		echo '<br/>';
		$result = openssl_decrypt($result, "sm4-cbc", $key, $options=0, $iv);
		echo($result);
	}

	public  function cs2 (){
		$key = '4f463e9435aa48fb801194f4ac6694f7';
		$keyBytes = base64_decode($key);

		$data = "sdZLeFk/oqT2sL9oAw3LQcrR5q0XZxZcmkiK5VU0/TPidBKDok0XPTrlIN4/+GFCiEAS23lbPaPuEMqSN94Z3MfOPpe4q4bQceZjEfXQrOi6sOOSwWmKLnzl/Un20hO9giWLbbuHPkProFxz1wIWdasPHhtLjSvd/B6DNi+8pjA=";
		$iv = pack("C*", 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31);
		$data = openssl_decrypt($data, "sm4-cbc", $keyBytes, $options=0, $iv);
		dump($data);
	}

	public function sm4(){
		$key = '4f463e9435aa48fb801194f4ac6694f7';
		

		// $data = '"{"'.
		// 		'"entId"'.':'.'"FFF95883CC824AFA987792D3CAE88FD0",'. 
		// 		'"wasteSupervisionCode":"神彩科技-20221026-0078",'.
		// 		'"remark":"取消称重"'.
		// 		'}';

		$data = "{" .
            "\"entId\":\"FFF95883CC824AFA987792D3CAE88FD0\"," .
            "\"packageCode\":\"神彩科技-20221026-0078\"".
            "}";

		// $data = "{" .
  //           "\"entId\":\"FFF95883CC824AFA987792D3CAE88FD0\"," .
  //           "\"packageCode\":\"神彩科技-20221026-0078\",".
  //           "\"remark\":\"取消称重\"".
  //           "}";

		$keyString = "4f463e9435aa48fb801194f4ac6694f7";
		$keyBytes = base64_decode($keyString);

		$key = substr($keyBytes, 0, 16);
		$iv = pack("C*", 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31);
		$result = openssl_encrypt($data, "sm4-cbc", $key, $options=0, $iv);
		echo($result);
		echo '<br/>';
		$result = openssl_decrypt($result, "sm4-cbc", $key, $options=0, $iv);
		echo($result);
	}

}

?>